/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package administrador;
import java.awt.Component;
import java.awt.Color;
import javax.swing.table.TableCellRenderer;
import javax.swing.JTable;
import javax.swing.JLabel;
import javax.swing.Icon;
import javax.swing.JTextField;
/**
 *
 * @author daniel1
 */
public class RenderCompras extends JLabel implements TableCellRenderer
 {
     private Icon[] iconos = null;
     /**
      * Constructor por defecto.
      */
     public RenderCompras(Icon[] iconos)
    {
        this.iconos = iconos;
     }
    
     public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) 
     {
         JLabel etiqueta = new JLabel();
         JTextField posible=new JTextField();
         posible.setFont(new java.awt.Font("Tahoma", 1, 11));
          Color col;
         Color colB;
         
         if(column==3){
             try{
                 if (String.valueOf(value).equals("null")) {
                 } else {
                     if (isSelected){ 
                     etiqueta.setIcon(iconos[0]);
                     }else{
                     etiqueta.setIcon(iconos[1]);
                     }
                 }
             //etiqueta.setToolTipText (Double.toString (valor));    
             } catch (Exception e) {
             }
         } else {
             if (String.valueOf(value).equals("null")) {
             } else {
                 posible.setText(String.valueOf(value));
                 if (isSelected){ 
                     col = new Color(166, 213, 230);
                     colB = new Color(9, 103, 141);
                     posible.setForeground(col);
                     posible.setBackground (colB);
                 }
                 return posible;
                 
             }
         }
         
         
     return etiqueta;   
     }
}
